package com.itlong.cloud.operate.dao;

import com.itlong.cloud.POJO.PO.AppPackagePO;
import com.itlong.cloud.POJO.VO.operate.OperateAppPackageGetPageVO;
import com.itlong.cloud.abstracts.IAbstractBaseDao;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <desc>
 *      运营-APP-套餐管理数据访问接口
 * </desc>
 *
 * @createDate 2017/11/01
 */
@Mapper
@Repository
public interface IOperateAppPackageDao extends IAbstractBaseDao<AppPackagePO> {
    /**
     * <desc>
     * 保存套餐
     * </desc>
     *
     * @param params 数据参数
     * @return sql执行行数
     * @author Jiaqi.X
     * @createDate 2017/11/01
     */
    Integer save(Map<String, Object> params);

    /**
     * <desc>
     * 修改套餐
     * </desc>
     *
     * @param params 数据参数
     * @return 执行行数
     * @author Jiaqi.X
     * @createDate 2017/11/01
     */
    Integer update(Map<String, Object> params);

    /**
     * <desc>
     * 获取分页数据集
     * </desc>
     *
     * @param params 查询参数
     * @return 分页数据集
     * @author Jiaqi.X
     * @createDate 2017/11/01
     */
    List<OperateAppPackageGetPageVO> getPage(Map<String, Object> params);

    /**
     * <desc>
     * 获取分页总数量
     * </desc>
     *
     * @param params 查询参数
     * @return 总数量
     * @author Jiaqi.X
     * @createDate 2017/11/01
     */
    Integer getPageCount(Map<String, Object> params);

    /**
     * <desc>
     * 删除套餐
     * </desc>
     *
     * @param appPackageIds 套餐id数组
     * @return sql执行行数
     * @author Jiaqi.X
     * @createDate 2017/11/01
     */
    Integer delete(@Param("appPackageIds") String[] appPackageIds, @Param("updateTime") Date updateTime);

    /**
     * <desc>
     * 删除套餐下的功能
     * </desc>
     *
     * @param appPackageId 套餐id
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/02
     */
    Integer deletePackageFunctions(@Param("appPackageId") String appPackageId, @Param("systemType") Integer systemType);

    /**
     * <desc>
     * 删除套餐关联的项目
     * </desc>
     *
     * @param appPackageId
     * @param projectIds
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/02
     */
    Integer deletePackageProject(@Param("appPackageId") String appPackageId, @Param("projectIds") String[] projectIds);

    /**
     * <desc>
     * 删除取消勾选的关联项目
     * </desc>
     *
     * @param appPackageId 套餐id
     * @param projectId    项目id
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/21
     */
    Integer deleteCancelAllotProject(@Param("appPackageId") String appPackageId, @Param("projectId") String projectId);

    /**
     * <desc>
     * 套餐分配项目
     * </desc>
     *
     * @param appPackageId 套餐id
     * @param projectIds   项目id
     * @param status       状态
     * @param createTime   创建时间
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/02
     */
    Integer allotPackageProject(@Param("appPackageId") String appPackageId,
                                @Param("projectIds") String[] projectIds,
                                @Param("status") Integer status,
                                @Param("createTime") Date createTime);

    /**
     * <desc>
     * 获取当前套餐已拥有的项目id集合
     * </desc>
     *
     * @param appPackageId 套餐id
     * @return
     * @author Jiaqi.X
     * @createDate 2017/11/02
     */
    List<String> getAppPackageProjectIds(@Param("appPackageId") String[] appPackageId);

    /**
     * <desc>
     * 获取已绑定套餐的项目id
     * </desc>
     *
     * @param appPackageId app套餐id
     * @return
     * @Author Zhu.yj
     * @createDate 2020/4/3
     */
    List<String> getOtherProjectIds(String appPackageId);

    /**
     * <desc>
     * 更新app套餐操作时间
     * </desc>
     *
     * @param params 参数map
     * @return
     * @Author Zhu.yj
     * @createDate 2020/4/9
     */
    Integer updateOperateTime(Map<String, Object> params);

    /**
     * <desc>
     * 通过套餐id列表删除套餐功能
     * </desc>
     *
     * @param appPackageIds 套餐id数组
     * @return
     * @Author Zhu.yj
     * @createDate 2020/4/9
     */
    Integer deleteFunctionByPackages(@Param("appPackageIds") String[] appPackageIds);

    /**
     * <desc>
     * 删除套餐关联的项目
     * </desc>
     *
     * @param appPackageIds 套餐id数组
     * @return
     * @Author Zhu.yj
     * @createDate 2020/4/9
     */
    Integer deleteProjectByPackages(@Param("appPackageIds") String[] appPackageIds);

    /**
     * <desc>
     * 根据套餐id获取场景id列表
     * </desc>
     *
     * @param appPackageId 套餐id
     * @return
     * @Author Zhu.yj
     * @createDate 2021/4/8
     */
    List<String> getSceneIdByPackageId(@Param("appPackageId") String appPackageId);

    /**
     * <desc>
     *      删除项目旧的套餐
     * </desc>
     *
     * @param projectIds 项目id数组
     * @return
     * @Author Zhu.yj
     * @createDate  2021/5/10
     */
    Integer deleteProjectOldPackages (@Param("projectIds") String[] projectIds);

    /**
     * <desc>
     *      删除用户项目
     * </desc>
     *
     * @param projectIds 项目id
     * @return
     * @Author Zhu.yj
     * @createDate  2021/5/10
     */
    Integer deleteUserFunctions(@Param("projectIds") List<String> projectIds);

    /**
     * <desc>
     *      校验项目是否绑定套餐
     * </desc>
     *
     * @param projectIds
     * @return
     * @Author Zhu.yj
     * @createDate  2021/5/19
     */
    List<Map<String, Object>> checkProjectsIsBindPackage(@Param("projectIds") List<String> projectIds);

}
